;          ELEKTUUR'S TIJDSEINPROCESSOR
;          'SECOND' SOURCE NAAR LISTING
;          IN ELEKTUUR 222 BLZ 41-43.
;
 .BA $0800
 .OS
 .MC $A000
;
;          PAGE ZERO
;
SWDAYA .DE $0000 SCHAKELDAGEN
;                      VOOR T0
TREG .DE $0001
SWTMAA .DE $0002 SCHAKELTIJDEN
;                      VOOR T0
COUNTA .DE $000A LIJNTELLER
COUNTB .DE $000B REGELTELLER
COUNTD .DE $000C
MDELAY .DE $000D
COUNTL .DE $000E
COUNTH .DE $000F
SWDAYB .DE $0010 SCHAKELDAGEN
;                      VOOR T1
BLNKCT .DE $0011
SWTMBA .DE $0012 SCHAKELTIJDEN
;                      VOOR T1
STOR .DE $001A
DUMP .DE $001B
INADL .DE $001C
INADH .DE $001D
SWDAYC .DE $0020 SCHAKELDAGEN
;                      VOOR T2
COUNTC .DE $0021
SWTMCA .DE $0022 SCHAKELTIJDEN
;                      VOOR T2
SWTMDA .DE $002A SCHAKELTIJDEN
;                      VOOR T3
SWDYA .DE $003E
SEC .DE $0048 INTERN
MIN .DE $0049 OPGEWEKTE
HOUR .DE $004A TIJD
CLDAY .DE $004B EN
WKDAY .DE $004C DATUM
MONTH .DE $004D
YEAR .DE $004E
MINO .DE $004F ONTVANGEN TIJD EN
HOURO .DE $0050 DATUM INFORMATIE
CLDAYO .DE $0051 VAN DE VORIGE
WKDAYO .DE $0052 MINUUT
MONTHO .DE $0053
YEARO .DE $0054
MINN .DE $0055 ONTVANGEN TIJD EN
HOURN .DE $0056 DATUM INFORMATIE
CLDAYN .DE $0057 VAN DE LOPENDE
WKDAYN .DE $0058 MINUUT
MONTHN .DE $0059
YEARN .DE $005A
TEMPX .DE $005B
TEMPY .DE $005C
PARITY .DE $005D
INDEX .DE $005E
SECDCF .DE $005F
FAIL .DE $0060
TEMP .DE $0061
KEY .DE $0062
DATA .DE $0063
TEMPBD .DE $0064
CNT .DE $0065
DPD .DE $0066 DISPLAY-BUFFERS
DPC .DE $0067
DPB .DE $0068
DPA .DE $0069
;
;           PIA ADRESSEN
;
PAD .DE $0080 6532 I/O EN
PADD .DE $0081 TIMER
PBD .DE $0082 ADRESSERING
PBDD .DE $0083
PEDGED .DE $0085
RDFLAG .DE $0087
CNTG .DE $009E
CNTH .DE $009F
LATCH .DE $0400 T0...T3
;                      UITGAVE-REGISTER
;
INITS CLD
 LDA #$FF
 TAX
SET INX
 STA *SWDAYA,X
 CPX #$3D
 BNE SET
 LDA #$88
LOAD INX
 STA *SWDAYA,X
 CPX #$47
 BNE LOAD
 LDA #$00
 STA *COUNTH
 STA *COUNTC
 STA LATCH
 TAX
CLRREG STA *SEC,X
 INX
 CPX #$3E
 BNE CLRREG
 INC *WKDAY
 INC *TEMP
 LDA #$7F
 STA *PADD
 STA *PBDD
 STA *FAIL
 TAX
 TXS
 CLI
 BRK
 NOP
 NOP
DCFCLK JSR DPTIME
 CMP #$FF
 BNE DCFCLK
DCF LDA *RDFLAG
 LDX #$00
 LDY #$00
DETECT BIT *RDFLAG
 BVC ONEMIN
 LDX #$00
INCX INX
INCY INY
 JSR DISPLY
 CPY #$28
 BEQ DECODE
 LDA *PAD
 BPL INCY
 BMI INCX
ONEMIN JSR DISPLY
 INX
 CPX #$28
 BNE DETECT
 LDA *SECDCF
 CMP #$59
 BNE RESET
 LDX #$96
DELAY JSR DISPLY
 DEX
 BNE DELAY
 LDX #$07
 LDY #$06
 JSR KLK
 LDX #$05
CHK LDA *MINO,X
 CMP *MINN,X
 BNE FAILT
 DEX
 BPL CHK
 LDX #$05
TRANSF LDA *MINN,X
 STA *MINO,X
 STA *MIN,X
 DEX
 BPL TRANSF
 JSR CLR
 LDX #$08
 STX *TEMP
 LDX #$D8
 STX *CNTH
 STA *SEC
 STA *FAIL
 BMI DCF
FAILT LDX #$05
TRFER LDA *MINN,X
 STA *MINO,X
 DEX
 BPL TRFER
RESET LDX #$FF
 STX *FAIL
 JSR CLR
 BMI DCF
DECODE CPX #$0A
 BCC RESET
 CPX #$1E
 BCC ZERO
 LDA #$80
 BNE ONE
ZERO LDA #$00
ONE STA *DATA
 LDY *SECDCF
 CPY #$20
 BCC INCSEC
 BEQ BEGCHK
 LDA *DATA
 BPL SHIFT
 INC *PARITY
SHIFT LDX *INDEX
 CPY #$28
 BEQ PARCHK
 CPY #$35
 BEQ SHRGHT
 CPY #$41
 BEQ SHIRR
 CPY #$44
 BEQ SHIR
 CPY #$49
 BEQ SHIRRR
 CPY #$57
 BEQ STDA
 CPY #$58
 BEQ PARCHK
 ORA *MINN,X
 LSR A
 STA *MINN,X
INCSEC LDX #$96
DLY JSR DISPLY
 DEX
 BNE DLY
 CLC
 TYA
 SED
 ADC #$01
 CLD
 STA *SECDCF
 JMP DCF
BEGCHK LDA *DATA
 BMI INCSEC
 BPL RESET
SHRGHT LSR *MINN,X
PARCHK LSR *PARITY
 BCS RESET
 LDA #$00
 STA *PARITY
 INC *INDEX
 BNE INCSEC
SHIRR ORA *MINN,X
SHI LSR A
 LSR A
STORE STA *MINN,X
 INC *INDEX
 BNE INCSEC
SHIR ORA *MINN,X
 LSR A
 LSR A
 LSR A
 BPL SHI
SHIRRR ORA *MINN,X
 LSR A
 BPL SHI
STDA ORA *MINN,X
 JMP STORE
CLR LDX #$0A
CL LDA #$00
 STA *MINN,X
 DEX
 BPL CL
 RTS
DSPLAY STX *TEMPX
 STY *TEMPY
 LSR *KEY
 BCC DPDATE
DPTIME LDX #$02
DPT LDA *SEC,X
 CPX #$02
 BNE DT
 JSR ZEROSU
DT STA *DPC,X
 DEX
 BPL DPT
 BMI DPWKDG
DPDATE LDA *CLDAY
 JSR ZEROSU
 STA *DPA
 LDA *MONTH
 JSR ZEROSU
 STA *DPB
 LDA *YEAR
 STA *DPC
DPWKDG LDX *WKDAY
 LDA #$7F
DWD SEC
 ROR A
 DEX
 BNE DWD
 STA *DPD
 LDA *FAIL
 BEQ DIS
 INC *BLNKCT
 INC *BLNKCT
 BPL DIS
 LDA #$FF
 STA *DPD
DIS JSR DISP
 LDX *TEMPX
 LDY *TEMPY
 RTS
ZEROSU TAY
 BEQ RTRN
 CMP #$0F
 BCS RTRN
 ORA #$F0
RTRN RTS
KLOK LDY #$00
 JSR INCDEC
 EOR #$60
 BNE RTN
 STA SEC,Y
KLK JSR INCDEC
 EOR #$60
 BNE RTN
 STA MIN,Y
 JSR INCDEC
 EOR #$24
 BNE RTN
 STA HOUR,Y
 JSR INCDEC
 JSR INCDEC
 CMP #$08
 BNE DAG
 LDA #$01
 STA WKDAY,Y
DAG LDA CLDAY,Y
 CMP #$29
 BMI RTN
 CMP #$31
 BMI FEBR
 ROR A
 BCC CLRKD
 LDA MONTH,Y
 CMP #$08
 BPL ASOND
 EOR #$FF
ASOND ROR A
 BCS CLRKD
 BCC RTN
FEBR LDA MONTH,Y
 CMP #$02
 BNE RTN
 LDA YEAR,Y
 AND #$13
 BEQ SCHRJR
 CMP #$12
 BNE CLRKD
SCHRJR LDA CLDAY,Y
 ROR A
 BCS RTN
CLRKD LDA #$01
 STA CLDAY,Y
 JSR INCDEC
 CMP #$13
 BNE RTN
 LDA #$01
 STA MONTH,Y
 JSR INCDEC
RTN RTS
INCDEC CLC
 LDA *SEC,X
 SED
 ADC #$01
 CLD
 STA *SEC,X
 INX
 RTS
IRQ PHA
 TYA
 PHA
 TXA
 PHA
 LDA #$00
 STA *PADD
 LDA *PBD
 STA *TEMPBD
 DEC *TEMP
 BEQ INCTIM
 LDA *TREG
 LDA #$79
 STA *CNTH
 BNE SAVE
INCTIM LDA #$82
 STA *CNTG
 LDA *INADH
 BEQ ASCII
 LDA *SEC
 BNE ASCII
 JSR TIMOUT
ASCII LDX #$00
 JSR KLOK
 JSR ASCIIO
 LDA #$09
 STA *TEMP
SAVE LDA *TEMPBD
 STA *PBD
 LDA #$7F
 STA *PADD
 PLA
 TAX
 PLA
 TAY
 PLA
 RTI
TIMOUT STA *TREG
 LDX #$02
TIME LDA #$00
 TAY
 TXA
 ASL A
 ASL A
 ASL A
 ASL A
 STA *COUNTL
 LDA (COUNTL),Y
 ASL A
 LDY *WKDAY
WEEKDY ASL A
 DEY
 BNE WEEKDY
 BCC TICTR
 LDA #$FE
 AND *TREG
 STA *TREG
 BCS NEXTL
TICTR INY
TIC INY
 LDA *HOUR
 CMP (COUNTL),Y
 BEQ MINCTR
 BCS INVTR
 BCC NEXTL
MINCTR LDA *MIN
 INY
 CMP (COUNTL),Y
 BCC NEXTL
 DEY
INVTR INY
 LDA #$01
 EOR *TREG
 STA *TREG
 CPY #$09
 BNE TIC
NEXTL ASL *TREG
 DEX
 BPL TIME
 ROR *TREG
TIMOD INX
 CPX #$14
 BEQ OUT
 JSR DAYNIB
 TYA
 CMP *WKDAY
 BCC TIMOD
 BNE OUT
 LDA *SWTMDA,X
 LSR A
 LSR A
 CMP *HOUR
 BEQ CHKMIN
 BCC NXTT
 BCS OUT
CHKMIN LDA *SWTMDA,X
 AND #$03
 TAY
 LDA *MIN
 CMP TABLE,Y
 BCC OUT
NXTT JMP TIMOD
OUT TXA
 AND #$01
 ASL A
 ASL A
 ASL A
 ORA *TREG
 STA LATCH
 RTS
DAYNIB TXA
 PHA
 LSR A
 TAX
 LDA *SWDYA,X
 BCC RNIB
 LSR A
 LSR A
 LSR A
 LSR A
SBN TAY
 PLA
 TAX
 RTS
RNIB AND #$0F
 BPL SBN
ASCIIO LDX #$00
OUTA TXA
 ORA #$60
 STA *PBD
 TXA
 CMP #$09
 BNE WKD
 INX
 TXA
WKD LSR A
 TAY
 BCC ONES
 LDA SEC,Y
 LSR A
 LSR A
 LSR A
 LSR A
 BPL TENS
ONES LDA SEC,Y
TENS AND #$0F
 ORA #$30
 STA *PBD
 INX
 CPX #$0E
 BNE OUTA
 RTS
DISP LDA #$40
 STA *DUMP
 LDX #$04
NEWBUF LDA #$02
 STA *INADL
NEWDIS LDA *CNT,X
 DEC *INADL
 BEQ SECDIS
 BMI READY
 LSR A
 LSR A
 LSR A
 LSR A
HEXSEG TAY
 LDA LOOKUP,Y
DISPL LDY *DUMP
 STY *PBD
 STA *PAD
 JSR DELA
 LDA *COUNTC
 CMP #$01
 BEQ ENDDIS
 AND *DUMP
 BEQ ENDDIS
 JSR DELA
ENDDIS DEY
 STY *PAD
 LSR *DUMP
 BPL NEWDIS
SECDIS AND #$0F
 BPL HEXSEG
READY DEX
 BEQ EXDLY
 CPX #$01
 BNE NEWBUF
DISDAY LDA *CNT,X
 JMP DISPL
EXDLY LDA *COUNTC
 BEQ REALIZ
 CMP #$01
 BNE GETKEY
REALIZ JSR DELA
GETKEY LDA #$00
 STA *PBD
 LDA #$BF
 STA *PAD
KEYDP LDA *PBD
 BNE STOKEY
 LDA *PAD
 ORA #$80
 ROR A
 STA *PAD
 BCS KEYDP
STOKEY LDA *PAD
 ORA #$80
 STA *KEY
 LDX #$FF
 STX *PAD
 TAX
 RTS
DELA LDY #$64
DLYDIS DEY
 BNE DLYDIS
RET RTS
DISPLY JSR DSPLAY
 CMP #$FD
 BNE RET
 JSR DISP
 LDX #$7F
 TXS
TIMER JSR CNTA
KNTAKT JSR DISP
 INX
 BNE KNTAKT
ASKKEY JSR DISP
 INX
 BEQ ASKKEY
 JSR DISP
 INX
 BEQ ASKKEY
 CMP #$EF
 BEQ JMPB
 CMP #$BF
 BEQ CLEAR
 CMP #$DF
 BEQ PROGRM
 CMP #$FD
 BEQ KLKSWT
 BNE ASKKEY
PROGRM JMP PROGR
JMPB JSR INCB
 JMP KNTAKT
CLEAR LDX #$FF
 STX *DPA
 STX *DPB
 LDA #$2A
 CMP *COUNTA
 BEQ CLTHRD
 LDA #$02
 CMP *COUNTB
 BNE CLTIME
 STX *DPD
CLTIME LDA #$0A
 CMP *COUNTB
 BEQ JSR
 JSR PUSHDA
 INC *COUNTB
 INC *COUNTB
 BPL CLTIME
JSR JSR INCA
 JMP KNTAKT
CLTHRD STX *DPD
CLTHLN JSR PUSHDA
 INC *COUNTB
 LDA #$14
 CMP *COUNTB
 BNE CLTHLN
 JSR CNTA
 JMP KNTAKT
KLKSWT JSR CNTA
VER LDA #$02
 CMP *COUNTB
 BEQ RADY
 LDA *DPA
 STA *STOR
 LDA *DPB
 STA *DUMP
 DEC *COUNTB
 DEC *COUNTB
 JSR GETAB
 LDA *DPA
 CMP *STOR
 BEQ VERMIN
 BCS ERROR
 BCC GOOD
VERMIN LDA *DPB
 CMP *DUMP
 BEQ GOOD
 BCS ERROR
GOOD INC *COUNTB
 INC *COUNTB
RADY LDA #$02
 CMP *COUNTA
 BNE NO
 LDA #$08
 CMP *COUNTB
 BEQ THIRDL
NO JSR INCB
 JMP VER
THIRDL JSR INCA
LABEL LDA *DPA
 STA *TEMPX
 LDA *DPB
 STA *TEMPY
 JSR DAYNIB
 CPY #$08
 BEQ END
 STY *STOR
 INX
 STX *COUNTB
 JSR GETDAT
 TYA
 CMP *STOR
 BCC ERROR
 BEQ NEXTSW
 BCS GOOOD
NEXTSW NOP
 LDA *DPA
 CMP *TEMPX
 BCC ERROR
 BEQ VRMINT
 BCS GOOOD
VRMINT LDA *DPB
 CMP *TEMPY
 BCC ERROR
GOOOD LDA *COUNTB
 CMP #$13
 BNE LABEL
END DEC *INADH
 JMP DCFCLK
ERROR LDA #$CD
 STA *DPA
 LDA #$DA
 STA *DPB
 LDA #$DF
 STA *DPC
 LDA #$FF
 STA *DPD
 STA *MDELAY
DEL JSR DISP
 DEC *MDELAY
 BNE DEL
 LDA #$2A
 CMP *COUNTA
 BEQ LASTLN
 JSR CNTB
 JMP KNTAKT
LASTLN JSR LINE
 JMP KNTAKT
PROGR LDX *DPA
 INX
 BNE CLEARC
 STX *DPA
 STX *DPB
CLEARC LDA #$80
 STA *COUNTC
 LDA #$2A
 CMP *COUNTA
 BEQ JUMPDY
 LDA #$02
 CMP *COUNTB
 BEQ JUMPDY
SHIFTC LSR *COUNTC
 LDA #$0C
 CMP *COUNTC
 BNE NEXTDP
 LDA #$04
 STA *COUNTC
NEXTDP LDA #$02
 CMP *COUNTC
 BEQ CLRC
 LDA #$40
 CMP *COUNTC
 BEQ HOURST
 LSR A
 CMP *COUNTC
 BEQ HOURSO
 LSR A
 CMP *COUNTC
 BEQ MINUTT
 LSR A
 CMP *COUNTC
 BEQ MINUTO
 JMP LINECH
JUMPDY JMP DAYCH
CLRC LDA #$00
 STA *COUNTC
 JMP KNTAKT
HOURST JSR KONTKT
 LDA *DPA
 CLC
 ADC #$10
 CMP #$24
 BCC HRST
 LDA #$00
HRST STA *DPA
 JMP HOURST
MINUTT JMP MNUTT
MINUTO JMP MNUTO
HOURSO JSR KONTKT
 INC *DPA
 LDA #$20
 AND *DPA
 BEQ HSRO
 LDA *DPA
 CMP #$24
 BNE HOURSO
 LDA #$20
 STA *DPA
 BPL HOURSO
HSRO LDA *DPA
 AND #$0F
 CMP #$0A
 BNE HOURSO
 LDA #$F0
 AND *DPA
 STA *DPA
 BPL HOURSO
MNUTT LDA #$2A
 CMP *COUNTA
 BEQ THRLNE
ADDONE JSR KONTKT
 LDA *DPB
 CLC
 ADC #$10
 CMP #$60
 BCC FAULTC
 LDA #$00
FAULTC STA *DPB
 JMP ADDONE
THRLNE LDA #$18
 STA *COUNTC
ADDMIN JSR KONTKT
 CLC
 LDA *DPB
 SED
 ADC #$15
 CLD
 CMP #$60
 BNE FAULTD
 LDA #$00
FAULTD STA *DPB
 JMP ADDMIN
MNUTO JSR KONTKT
 INC *DPB
 LDA *DPB
 AND #$0F
 CMP #$0A
 BNE MNUTO
 LDA #$F0
 AND *DPB
 STA *DPB
 BPL MNUTO
LINECH JSR KONTKT
 LDX #$2A
 CPX *COUNTA
 BNE NXTLNE
 LDX #$FF
 STX *COUNTA
NXTLNE JSR INCA
 JMP LINECH
DAYCH LDA #$00
 STA *COUNTC
KNTKT JSR PIEKDP
 INX
 BNE KNTKT
ASKKE JSR PIEKDP
 INX
 BEQ ASKKE
 JSR PIEKDP
 INX
 BEQ ASKKE
 CMP #$DF
 BEQ JMP
 CMP #$EF
 BEQ GONE
 CMP #$FB
 BNE ASKKE
 LDA #$2A
 CMP *COUNTA
 BEQ THRDDY
 LDA #$80
 STA *COUNTD
 LDA #$FF
 STA *DPD
SHIFTD LSR *COUNTD
KONTK JSR DAYKNP
 INX
 BNE KONTK
ASK JSR DAYKNP
 INX
 BEQ ASK
 JSR DAYKNP
 INX
 BEQ ASK
 CMP #$DF
 BEQ JMP
 CMP #$EF
 BEQ GONE
 CMP #$FB
 BEQ DAYKEY
 CMP #$F7
 BNE ASK
 LDA *COUNTD
 EOR *DPD
 STA *DPD
DAYKEY LDA #$01
 CMP *COUNTD
 BNE SHIFTD
 JMP KNTKT
JMP JSR PUSHDA
 LDA #$80
 STA *COUNTC
 JMP SHIFTC
GONE JSR PUSHDA
 JMP JMPB
THRDDY LDY #$01
 LDX *COUNTB
 BEQ SEARCH
 DEX
 JSR DAYNIB
SEARCH LDA DTABLE,Y
 STA *DPD
 EOR #$FF
 STA *COUNTD
KNTK JSR DAYKNP
 INX
 BNE KNTK
KEYDEP JSR DAYKNP
 INX
 BEQ KEYDEP
 JSR DAYKNP
 INX
 BEQ KEYDEP
 CMP #$FB
 BEQ NXTDAY
 CMP #$F7
 BNE KEYDEP
 JMP DAYCH
NXTDAY LSR *COUNTD
 LDA *COUNTD
 BEQ THRDDY
 SEC
 ROR *DPD
 BMI KNTK
CNTA LDA #$FF
 STA *COUNTA
INCA INC *COUNTA
 LDA #$03
 CMP *COUNTA
 BEQ LINE
CNTB LDA #$00
 STA *COUNTB
INCB LDA #$2A
 CMP *COUNTA
 BEQ INCBL
 INC *COUNTB
 INC *COUNTB
 LDA #$0A
 CMP *COUNTB
 BEQ INCA
 JSR GETAB
 RTS
LINE LDA #$2A
 STA *COUNTA
 LDA #$FF
 STA *COUNTB
INCBL INC *COUNTB
 LDA #$14
 CMP *COUNTB
 BEQ CNTA
 JSR GETDAT
 RTS
GETAB LDA #$00
 TAY
 STA *INADH
 LDA *COUNTA
 ASL A
 ASL A
 ASL A
 ASL A
 TAX
 ORA *COUNTB
 STA *INADL
 LDA (INADL),Y
 STA *DPA
 INC *INADL
 LDA (INADL),Y
 STA *DPB
 STX *INADL
 LDA *COUNTB
 ROR A
 ROR A
 BCC SWOUT
 LDA #$0B
SWITCH ORA *INADL
 STA *DPC
 STX *INADL
 LDA (INADL),Y
 STA *DPD
 RTS
SWOUT LDA #$0A
 BPL SWITCH
GETDAT LDA *COUNTB
 TAX
 LDA *SWTMDA,X
 TAY
 INY
 BEQ TIMCLR
 AND #$FC
 LSR A
 LSR A
 STA *DPA
 LDA *SWTMDA,X
 AND #$03
 TAY
 LDA TABLE,Y
 STA *DPB
DPABR TXA
 LSR A
 BCC INOUT
 LDA #$0A
PUTAWY ORA #$30
 STA *DPC
 JSR DAYNIB
 LDA DTABLE,Y
 STA *DPD
 RTS
TIMCLR DEY
 STY *DPA
 STY *DPB
 BMI DPABR
INOUT LDA #$0B
 BPL PUTAWY
PUSHDA LDA *COUNTA
 CMP #$2A
 BEQ PUSHDT
 ASL A
 ASL A
 ASL A
 ASL A
 STA *INADL
 LDY #$00
 LDA *DPD
 STA (INADL),Y
 LDY *COUNTB
 LDA *DPA
 STA (INADL),Y
 INY
 LDA *DPB
 STA (INADL),Y
 RTS
PUSHDT LDY #$00
 LDA *COUNTB
 TAX
 LDA *DPA
 ASL A
 ASL A
 STA *SWTMDA,X
 LDA *DPB
 BEQ PUSH
 INY
 CMP #$15
 BEQ PUSH
 INY
 CMP #$30
 BEQ PUSH
 INY
PUSH TYA
 ORA *SWTMDA,X
 STA *SWTMDA,X
 LDY #$00
 LDA #$7F
PHDAYS INY
 SEC
 ROR A
 CMP *DPD
 BNE PHDAYS
 TXA
 LSR A
 TAX
 LDA *SWDYA,X
 BCC RNIBDY
 AND #$0F
 STA *SWDYA,X
 TYA
 ASL A
 ASL A
 ASL A
 ASL A
 ORA *SWDYA,X
 STA *SWDYA,X
 RTS
RNIBDY AND #$F0
 STA *SWDYA,X
 TYA
 ORA *SWDYA,X
 STA *SWDYA,X
 RTS
KONTKT JSR KNIP
 INX
 BNE KONTKT
ASKKY JSR KNIP
 INX
 BEQ ASKKY
 JSR KNIP
 INX
 BEQ ASKKY
 CMP #$DF
 BEQ GO
 CMP #$EF
 BEQ GOON
 CMP #$FB
 BNE ASKKY
 RTS
GO TSX
 INX
 INX
 TXS
 JSR PUSHDA
 JMP SHIFTC
GOON LDA #$00
 STA *COUNTC
 TSX
 INX
 INX
 TXS
 JMP GONE
KNIP LDA *COUNTC
 STA *STOR
 INC *MDELAY
 INC *MDELAY
 BPL KNP
 LDA #$00
 STA *COUNTC
KNP JSR DISP
 LDY *STOR
 STY *COUNTC
 RTS
PIEKDP INC *MDELAY
 LDA #$70
 AND *MDELAY
 BNE DPLAY
 LDA *DPD
 EOR #$FF
 STA *DPD
 JSR DISP
 LDA *DPD
 EOR #$FF
 STA *DPD
PK LDA *KEY
 RTS
DPLAY JSR DISP
 BNE PK
DAYKNP INC *MDELAY
 INC *MDELAY
 BPL DPLY
 LDA *DPD
 STA *STOR
 LDA *COUNTD
 EOR *DPD
 STA *DPD
 JSR DISP
 LDA *STOR
 STA *DPD
DYKNP LDA *KEY
 RTS
DPLY JSR DISP
 BNE DYKNP
NMI CLC
HWCHCK BCC HWCHCK
 .BY $FF
 .BY $FF
 .BY $FF
LOOKUP .BY $40 ;0
 .BY $79 ;1
 .BY $24 ;2
 .BY $30 ;3
 .BY $19 ;4
 .BY $12 ;5
 .BY $02 ;6
 .BY $78 ;7
 .BY $00 ;8
 .BY $10 ;9
 .BY $23 ;o
 .BY $7B ;i
 .BY $06 ;E
 .BY $2F ;r
 .BY $FF ;BLANK
DTABLE .BY $FF ;BLANK
 .BY $BF ;MONDAY
 .BY $DF ;TUESDAY
 .BY $EF ;WEDNESDAY
 .BY $F7 ;THIRSDAY
 .BY $FB ;FRIDAY
 .BY $FD ;SATURDAY
 .BY $FE ;SUNDAY
 .BY $FF ;BLANK
TABLE .BY $00 ;00
 .BY $15 ;15
 .BY $30 ;30
 .BY $45 ;45
 .BY $FF ;BLANK
 .BY $FF ;BLANK
 .BY $FF ;BLANK
NMIL .BY $D5
NMIH .BY $0F
RSTL .BY $00
RSTH .BY $08
IRQL .BY $16
IRQH .BY $0A
;
 .EN
